package com.cxx.purchasecharge.dal;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.cxx.purchasecharge.core.model.persistence.Accounting;
import com.cxx.purchasecharge.dal.common.GenericCRUDDao;

@Transactional
public interface AccountingDao extends GenericCRUDDao <Accounting, Long>, AccountingDaoPlus
{
    public Accounting findById (long id);

    @Query (value = "select a from Accounting a where a.payAccountId=?1")
    public List <Accounting> findByPayAccountId (long payAccountId);

    @Query (value = "select a from Accounting a where a.type.id=?1")
    public List <Accounting> findByType (long typeId);

    @Query (value = "select a from Accounting a where a.userCreatedBy=?1")
    public List <Accounting> findByUserCreatedBy (long userCreatedBy);
    
    @Query (value = "select a from Accounting a where a.type.id=?1 and a.created between ?2 and ?3 order by a.created desc")
    public List <Accounting> findByTypeAndTimeRange (long typeId, Date start, Date end);
    
    @Query (value = "select a from Accounting a where a.created between ?1 and ?2 order by a.created desc")
    public List <Accounting> findByTimeRange (Date start, Date end);

}
